$(function(){
	$('iframe[name="UploadImage"]').before('<iframe name="UploadFrame" style="display:none;"></iframe>');
	window.frames['UploadImage'].document.body.innerHTML = '<div style="height:24px;overflow:hidden;left:0;top:0;position:absolute;"><form name="UploadForm" action="'+RaysnWeb.settings.basePath+RaysnWeb.settings.uploadPath+'" method="post" target="UploadFrame" enctype="multipart/form-data"><input type="file" name="UploadImage" size="18" /><input type="submit" name="confirm" value="上传图片" /></form></div>';

	$('.ImageList dl dt').live('click',function(){
		$('.ImageList dl dt').css('border-color','#ECE9D8');
		$(this).css('border-color','red');
		$(':input[name="image"]').val( $(this).siblings('dd').find('a').attr('name') );
	});
	$('.ImageList dl dd a').live('click',function(){
		var Image = $(this);

		$.ajax({
			type: "get",
			url: RaysnWeb.settings.basePath +RaysnWeb.settings.deletePath+ this.name,
			data: 'ajax=&confirm=ok',
			dataType: 'json',
			success: function( Result ) {
				if ( Result == null ) {
					Image.parent().parent().remove();
				} else {
					RaysnWeb.showClewbox(Result.Message);
				}
			},
			error: function( ) {
			}
		});
		return false;
	});
});

RaysnWeb.createImageList = function(pid,src) {
	$('#ImageList,.ImageList').append('<dl><dt title="设为封面"><b><span></span><img src="'+src+'" /></b></dt><dd><a href="#" name="'+pid+'">删除</a></dd></dl>');
}
